<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    * {
      margin: 0;
      padding: 0;
    }
    body {
      width: 100vw;
      height: 100vh;
      background: #34495e;
      display: flex;
      justify-content: center;
      align-items: center;
    }
    main {
      width: 400px;
      height: 400px;
      border: 1px solid #ddd;
    }
    div {
      width: 100px;
      height: 100px;
      background: #f1c40f;
      animation-name: ani2, ani3; /* 如果再有ani4 不加时间，时间会从头开始 */
      animation-duration: 4s, 2s;
      animation-iteration-count: 2, 1, 1; /* infinite */
    }
    @keyframes ani2 {
      /* from {
        transform: translate(0, 0);
      } */
      25% {
        transform: translateX(300px);
      }
      50% {
        transform: translate(300px, 300px);
        /* background-color: #f1c40f; */
        border-radius: 0;
      }
      75% {
        transform: translateY(300px);
      }

      25%, 75% {
        /* background-color: #9b59b6; */
        border-radius: 50%;
      }
      /* to {
        transform: translate(0, 0);
      } */
    }
    @keyframes ani3 {
      25% {
        background: #2ecc71;
      }
      50% {
        background: #e67e22;
      }
      75% {
        background: #9b59b6;
      }
    }
    /* main {
      width: 100px;
      height: 100px;
      background-color: white;
      animation-name: ani1;
      animation-duration: 2s;
    } */
    @keyframes ani1 {
      /* from {
        background-color: white;
      }
      to {
        background-color: #e74c3c;
      } */
      0% {
        background-color: white;
      }
      25% {
        transform: scale(2);
      }
      65% {
        transform: scale(1);
        background: #9b59b6;
      }
      100% {
        background-color: #e74c3c;
      }
    }
  </style>
</head>
<body>
  <main>
    <div></div>
  </main>
</body>
</html>